package com.mashibing.apipassenger.service;

import com.mashibing.apipassenger.remote.ServicePassengerUserClient;
import com.mashibing.internalcommon.dto.PassengerUser;
import com.mashibing.internalcommon.dto.ResponseResult;
import com.mashibing.internalcommon.dto.TokenResult;
import com.mashibing.internalcommon.request.VerificationCodeDTO;
import com.mashibing.internalcommon.util.JwtUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 史慕尧
 */
@Service
@Slf4j
public class UserService {
    @Autowired
    ServicePassengerUserClient servicePassengerUserClient;

public ResponseResult getUserByAccessToken(String accessToken){
    //解析拿到手机号
    log.info("accessToken"+accessToken);
    TokenResult tokenResult = JwtUtils.parseToken(accessToken);
    String phone = tokenResult.getPhone();
    System.out.println("手机号"+phone);
    VerificationCodeDTO verificationCodeDTO = new VerificationCodeDTO();
    verificationCodeDTO.setPassengerPhone(phone);
    //手机号查询
    ResponseResult userByPhone = servicePassengerUserClient.getUserByPhone(phone);
    //返回对象封装


    return ResponseResult.success(userByPhone);

}
}
